from django.core.mail import send_mail
from celery_tasks.main import app
from django.conf import settings

from haoke_mall.settings.dev import EMAIL_FROM

@app.task(name='send_verify_email')
def send_verify_email(to_email,verify_url):
    """

    :param to_email: 收件人的邮箱
    :param verify_url: 激活链接
    :return:
    """
    subject = '好课商城邮箱验证'
    html_message = '<p>尊敬的用户您好！</p>' \
                   '<p>感谢您使用好课商城。</p>' \
                   '<p>您的邮箱为：%s 。请点击此链接激活您的邮箱：</p>' \
                   '<p><a href="%s">%s<a></p>' % \
                   (to_email, verify_url, verify_url)

    # send_mail(subject,'',settings.EMAIL_FROM,[to_email],html_message=html_message)
    # send_mail(subject=subject,message='',from_email=settings.EMAIL_FROM,recipient_list=[to_email],html_message=html_message)
    send_mail(
        subject=subject,
        message='',
        # from_email=settings.EMAIL_FROM,   # 这里改为从主设置文件中导入
        from_email=EMAIL_FROM,   # 这里是子设置文件
        recipient_list=[to_email, ],
        html_message=html_message
    )


